package com.example.demo.controller;

import com.example.demo.Mappers.RegistMapper;
import com.example.demo.Service.RegistPatientService;
import com.example.demo.beans.RegistPatientInfoRequest;
import com.example.demo.beans.RegistPatientInfoResponse;
import org.apache.ibatis.annotations.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**绑定就诊卡
 * Created by Administrator on 2018/4/7.
 */
@RestController
public class RegistPatientController {
    @Autowired
    RegistMapper registMapper;
    @Autowired
    @Qualifier("RegistPatientService")
    private RegistPatientService patientService;

    @ResponseBody
    @RequestMapping(value ="RegistPatientInfo" , produces = {"application/xml"})
    public RegistPatientInfoResponse RegistPatient(@RequestBody RegistPatientInfoRequest request){
        if(request!=null){
            String tempid=request.getPatientID().trim();
            if(!request.getPatientID().isEmpty()){
                System.out.print("这个是"+request.getPatientID()+"病人");
                System.out.print("这里不为空");
                return patientService.ResponseWithIspatient(request);
            }
            //当是身份证注册时候
            else  if(request.getCardNo().trim().length()==18){
                return  patientService.ResponseByOtherCard(request);
            }
            else {
                System.out.print("执行到这里");
                return    patientService.RensonseWithNopatient(request);

            }

        }

        else {RegistPatientInfoResponse registPatientInfoResponse=new RegistPatientInfoResponse();
        registPatientInfoResponse.setResultCode("1");
        registPatientInfoResponse.setResultMsg("提示：请求参数为空，请检查！");
      return  registPatientInfoResponse;
        }

    }
}
